<?php

namespace addons\TfFutures;

use Yii;
use backend\interfaces\AddonWidget;

class UnInstall implements AddonWidget
{
    /**
     * 表前缀
     * @var string
     */
    protected $table_prefixion = "rf_addon_tf_futures_";

    /**
     * 列表
     * @var array
     */
    protected $table_name = [
        'adv',
        'article',
        'article_cate',
        'article_single',
        'article_tag',
        'article_tag_map',
        'bankinfo',
        'complaint',
        'daili_withdraw',
        'level',
        'logs',
        'member',
        'member_lever',
        'msg',
        'notice',
        'order',
        'order_reason',
        'symbol',
        'symbol_cate',
        
    ];

    /**
     * @param $addon
     * @return mixed|void
     * @throws \yii\db\Exception
     */
    public function run($addon)
    {
        $sql = "";
        foreach ($this->table_name as $value) {
            $table = $this->table_prefixion . $value;
            $sql   .= "DROP TABLE IF EXISTS `{$table}`;";
        }
        // 执行sql
        Yii::$app->getDb()
                 ->createCommand($sql)
                 ->execute();
    }
}
